//
//  ShopCartTaoCanCell.m
//  FD
//
//  Created by Yasin on 2018/10/25.
//  Copyright © 2018 ZhiYuan Network. All rights reserved.
// 订单 套餐cell
/**
 标题      餐品说明
 折扣价 原价
 */
//4:20 ----
#import "ShopCartTaoCanCell.h"
@interface ShopCartTaoCanCell()
/**背景*/
@property (nonatomic,  strong) UIView *bgView;
/**1.name*/
@property (nonatomic,  strong) UILabel *nameLb;
/**2.折扣价*/
@property (nonatomic,  strong) UILabel *discountPriceLb;
/**4.参数详情lb*/
@property (nonatomic,  strong) UILabel *descLb;


@end

@implementation ShopCartTaoCanCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style
                reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setupView {
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.nameLb];
    [self.bgView addSubview:self.discountPriceLb];
//    [self.bgView addSubview:self.originPriceLb];
    [self.bgView addSubview:self.descLb];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(10);
        make.top.equalTo(self.bgView.mas_top).offset(5);
        make.height.mas_equalTo(22);
        make.right.equalTo(self.descLb.mas_left);
    }];
    [self.discountPriceLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLb.mas_left);
        make.size.mas_equalTo(CGSizeMake(60, 20));
        make.top.equalTo(self.nameLb.mas_bottom).offset(3);
    }];
    
    [self.descLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(80, 44));
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.right.equalTo(self.bgView.mas_right).offset(-5);
    }];
}

#pragma mark - setter
- (void)setModel:(ShopCartModel *)model {
    _model = model;
    
    FDLog(@"购物车模型:%@",model);
    
    self.nameLb.text = model.title;
    self.discountPriceLb.text = [NSString stringWithFormat:@"￥%.1f",[model.discount_price floatValue]];
    
    //拼接套餐详情数据
    NSMutableString *strM = [NSMutableString string];
    for (ShopCartSetMealMode *mealModel in model.setMeal) {
        //注意使用 appendFormat:
        [strM appendFormat:@"%@",mealModel.name];
    }
    self.descLb.text = strM;
}

#pragma mark - getter
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
    }
    return _bgView;
}
-(UILabel *)nameLb {
    if (!_nameLb) {
        _nameLb = [UILabel new];
        _nameLb.text = @"外送全家桶";
        _nameLb.backgroundColor = [UIColor lightGrayColor];
    }
    return _nameLb;
}
- (UILabel *)discountPriceLb {
    if (!_discountPriceLb) {
        _discountPriceLb = [UILabel new];
        _discountPriceLb.text = @"￥78.";
        _discountPriceLb.font = [UIFont systemFontOfSize:16.0*kScaleFit];
        _discountPriceLb.textColor = [UIColor redColor];
        _discountPriceLb.backgroundColor = [UIColor yellowColor];
    }
    return _discountPriceLb;
}

- (UILabel *)descLb {
    if (!_descLb) {
        _descLb = [UILabel new];
        _descLb.textColor = [UIColor lightGrayColor];
        _descLb.text = @"外送全家桶外送全家桶*90外送全家桶外送全家桶";
        _descLb.font = [UIFont systemFontOfSize:13.0*kScaleFit];
        _descLb.numberOfLines = 0; //自动换行
        _descLb.backgroundColor = [UIColor redColor];
    }
    return _descLb;
}
#pragma mark - layout
#pragma mark - getter

@end
